#pragma once

#include <d2d1_1.h>
#include <initguid.h>
#include <d2d1effectauthor.h>  
#include <d2d1effecthelpers.h>

DEFINE_GUID(CLSID_Polaroid, 0x59820389, 0xbbd5, 0x40e8, 0x9a, 0xf2, 0x30, 0x9b, 0xb2, 0x94, 0xb3, 0x95);

class PolaroidEffect: public ID2D1EffectImpl
{
public:
    IFACEMETHODIMP Initialize(
        _In_ ID2D1EffectContext* pContextInternal,
        _In_ ID2D1TransformGraph* pTransformGraph
        );

    IFACEMETHODIMP PrepareForRender(D2D1_CHANGE_TYPE changeType);
    IFACEMETHODIMP SetGraph(_In_ ID2D1TransformGraph* pGraph);

    static HRESULT Register(_In_ ID2D1Factory1* pFactory);
    static HRESULT __stdcall CreateEffect(_Outptr_ IUnknown** ppEffectImpl);

    IFACEMETHODIMP_(ULONG) AddRef();
    IFACEMETHODIMP_(ULONG) Release();
    IFACEMETHODIMP QueryInterface(_In_ REFIID riid, _Outptr_ void** ppOutput);

	// Properties
    float GetForce() const;
    HRESULT SetForce(float force);

private:
    PolaroidEffect();

    LONG m_refCount; 
	float m_force;

	ComPtr<ID2D1Effect> m_pColorMatrixBWEffect;
	ComPtr<ID2D1Effect> m_pColorMatrixSepiaEffect;
	ComPtr<ID2D1Effect> m_pBrightnessEffect;
	ComPtr<ID2D1Effect> m_pHueEffect;
	ComPtr<ID2D1Effect> m_pSaturationEffect;
	ComPtr<ID2D1TransformNode> m_pSaturationTransform;
	ComPtr<ID2D1TransformNode> m_pHueTransform;
	ComPtr<ID2D1TransformNode> m_pBrightnessTransform;
	ComPtr<ID2D1TransformNode> m_pColorMatrixBWTransform;
	ComPtr<ID2D1TransformNode> m_pColorMatrixSepiaTransform;
};

